import * as jwt from 'jsonwebtoken';

import EXPIRESIN from '../../constants/token';

class TokenUtil {
  /**
   * 用于在用户登录的时候对返回的数据用jwt进行加密返回token
   * @param {object} params 加密对象
   */
  static async createToken(params) {
    return jwt.sign(params, process.env.TOKEN_SECRET as jwt.Secret, {
      expiresIn: EXPIRESIN,
    });
  }
}

export default TokenUtil;
